#!/bin/bash
set -e

function info() {
echo Usage: `basename $0` 'file_path name_list target_tag'

cat <<info
info
exit 65
}

function error() {
echo `basename $0`': invalid option --'
echo Usage: `basename $0` 'file_path name_list target_tag'

cat <<error
error
exit 65
}

while getopts ":w:p:h" opts
do
case $opts in
w) win_size=$OPTARG;;
p) out_prefix=$OPTARG;;
h) info;;
\?) error;;
esac
done
shift $(($OPTIND - 1))

test $# -lt 1 && info

. $var

for name in $(cat $2); do
 
	# i=0
	# for r in $(ls ${1}/*${dir}*); do
	# let i+=1

	# cd $dir && ln -s $r ${dir}_atgc_L001_R${i}_001.fq.gz && cd -
	
	# done
	if test `ls $1 |grep "${name}_" |grep '_R1.f' |wc -l|cut -d' ' -f1` -eq 1; then
		mkdir $name
		r1=$1/`ls $1 |grep "${name}_" |grep '_R1.f'`
		r2=$1/`ls $1 |grep "${name}_" |grep '_R2.f'`
		echo $r1 $r2
		ln -s $r1 $name/${name}_ATCG_L000_R1_000.fastq.gz
		ln -s $r2 $name/${name}_ATCG_L000_R2_000.fastq.gz
		
	fi
	
# snp_0202.sh -s$name -i$3 $name
	
done

. $cmd_done